/**
 * <p>Copyright: Copyright (c) 2014</p>
 * <p>Company: ---Technology Co. Ltd</p>
 * <p>2014-4-30</p>
 * @author Jan.Zhang
 */
package com.xianl.busiplat.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xianl.busiplat.dwz.AjaxObject;
import com.xianl.busiplat.service.CacheService;


/** 
 * desc:
 * <p>author: Jan.Zhang </p>
 * date: 2014-4-30
 */
@Controller
@RequestMapping("/sys/core/cacheManage")
public class CacheManageController {

	private static Logger log = LoggerFactory.getLogger(CacheManageController.class);
	@Autowired
	private CacheService cacheService;
	private static final String INDEX = "sys/core/cacheManage/index";

	@RequiresPermissions("CacheManage:view")
	@RequestMapping(value = "/index", method = RequestMethod.GET)
	public String index() {
		return INDEX;
	}

	@RequiresPermissions("CacheManage:edit")
	@RequestMapping(value = "/clear", method = RequestMethod.POST)
	public @ResponseBody
	String clear() {
		cacheService.clearAllCache();
		log.info("清空缓存成功！");
		AjaxObject ajaxObject = new AjaxObject("清除缓存成功！");
		ajaxObject.setCallbackType("");
		return ajaxObject.toString();
	}
}
